<template>
  <div class="no-permission-container">
    <div class="no-permission-content">
      <div class="icon">
        <i class="el-icon-lock"></i>
      </div>
      <h2 class="title">无访问权限</h2>
      <p class="desc">您没有权限访问该页面，请联系管理员获取对应权限</p>
      <div class="btn-group">
        <el-button type="primary" @click="goHome">返回首页</el-button>
        <el-button @click="goLogin">重新登录</el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/modules/user'

const router = useRouter()
const userStore = useUserStore()

// 返回对应角色首页
const goHome = () => {
  const role = userStore.role
  if (role === 'super_admin') {
    router.push('/super-admin/user-manage')
  } else if (role === 'merchant') {
    router.push('/merchant/product-manage')
  } else if (role === 'doctor') {
    router.push('/doctor/doctor-info')
  } else {
    router.push('/login')
  }
}

// 重新登录（清除状态）
const goLogin = () => {
  userStore.logout()
  router.push('/login')
}
</script>

<style scoped lang="scss">
.no-permission-container {
  width: 100vw;
  height: 100vh;
  background-color: #f5f7fa;
  display: flex;
  align-items: center;
  justify-content: center;
}

.no-permission-content {
  text-align: center;
  padding: 50px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 20px 0 rgba(0, 0, 0, 0.08);
  width: 450px;
}

.icon {
  font-size: 80px;
  color: #f56c6c;
  margin-bottom: 25px;
}

.title {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
}

.desc {
  font-size: 16px;
  color: #666;
  margin-bottom: 30px;
  line-height: 1.6;
}

.btn-group {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.el-button {
  padding: 10px 30px;
  font-size: 16px;
}
</style>